package com.oss.service;

import com.oss.model.Dealer;
import com.oss.model.Employee;

public class EmployeeService {
    private static final Employee employeeDao = new Employee().dao();
    private static final Dealer dealerDao = new Dealer().dao();


    /**
     * 店员账号登录
     *
     * @param account
     * @return
     */
    public Employee loginByEmployee(String account) {
        return employeeDao.findFirst("SELECT * FROM employee WHERE account=?", account);
    }

    /**
     * 根据id查找
     */
    public Employee findById(String employeeId) {
        Employee employee = employeeDao.findById(employeeId);
        if (employee != null) {
            Dealer dealer = dealerDao.findById(employee.getDealerId());
            String dealerName = "";
            if (dealer != null) {
                dealerName = dealer.getName();
            }
            employee.put("dealerName", dealerName);
            employee.remove("password");
        }
        return employee;
    }

}
